<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Js 核心语法</title>
    <link rel="stylesheet" href="resource\main.css" />
    <script>
      window.onload = function () {
        console.log("文档加载完毕");
      };

      let today = "2022-11-01";
      const 常量 = "常量的值";
      console.log(today, 常量);
      console.log(5 == "5", 5 === "5");

      if (today == "2022-11-01") {
        console.log("又是阳光明媚的一天。");
      } else {
        console.log("又是躺平的一天。");
      }

      for (let i = 0; i < 5; i++) {
        console.log(i);
      }

      // while(today == '2022-11-01') {
      //     console.log('又是阳光明媚的一天。');
      // }

      // 定义函数
      function p(str) {
        console.log(str);
      }

      // 定义有返回值的函数
      function hi(name = "小明", message) {
        return name + message;
      }

      // Don't Repeat Yourself

      p("又是一天");
      p(hi("小欧"));
      p(hi());

      // 对象类型

      let stu1 = {
        id: "P212121222",
        专业: "编导",
        hi: function () {
          console.log("hi");
        },
      };

      p(stu1["专业"]);

      p(stu1.id);
      stu1.hi();
    </script>
    <script src="resource\js\bdtj.js"></script>
  </head>

  <body>
    <h1>JavaScript 核心语法</h1>
    <div id="active">使用脚本获取及修改元素的内容</div>

    <script>
      let oLi = document.getElementById("active");
      console.log(oLi.innerHTML);
      oLi.innerHTML = "<a href='http://www.baidu.com'>Baidu</a>";
    </script>
  </body>
</html>
